using MediatR;
using B.S.XZYData.ErrorCode;
using System;
using System.Collections.Generic;

namespace B.S.XZYData.Api.Read.Application.Command.Approval
{
    /// <summary>
    /// 查询待审批列表命令
    /// </summary>
    public class QueryPendingApprovalsCommand : IRequest<ApiResult<PendingApprovalPageResult>>
    {
        /// <summary>
        /// 页码
        /// </summary>
        public int PageIndex { get; set; } = 1;

        /// <summary>
        /// 每页大小
        /// </summary>
        public int PageSize { get; set; } = 30;

        /// <summary>
        /// 工单编号
        /// </summary>
        public string? WorkOrderCode { get; set; }

        /// <summary>
        /// 工序名称
        /// </summary>
        public string? ProcessName { get; set; }

        /// <summary>
        /// 申请人
        /// </summary>
        public string? ApplicantUserName { get; set; }

        /// <summary>
        /// 流程状态（发起、处理中、通过、驳回）
        /// </summary>
        public string? Status { get; set; }

        /// <summary>
        /// 申请时间开始
        /// </summary>
        public DateTime? CreateTimeStart { get; set; }

        /// <summary>
        /// 申请时间结束
        /// </summary>
        public DateTime? CreateTimeEnd { get; set; }

        /// <summary>
        /// 当前审批人ID（用于权限控制）
        /// </summary>
        public string? CurrentAuditUserId { get; set; }
    }

    /// <summary>
    /// 待审批分页结果
    /// </summary>
    public class PendingApprovalPageResult
    {
        /// <summary>
        /// 总记录数
        /// </summary>
        public int TotalCount { get; set; }

        /// <summary>
        /// 当前页码
        /// </summary>
        public int PageIndex { get; set; }

        /// <summary>
        /// 每页大小
        /// </summary>
        public int PageSize { get; set; }

        /// <summary>
        /// 总页数
        /// </summary>
        public int TotalPages { get; set; }

        /// <summary>
        /// 数据列表
        /// </summary>
        public List<PendingApprovalDto> Data { get; set; } = new List<PendingApprovalDto>();
    }

    /// <summary>
    /// 待审批项目DTO
    /// </summary>
    public class PendingApprovalDto
    {
        /// <summary>
        /// 流程实例ID
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 流程实例唯一标识
        /// </summary>
        public string WorkflowId { get; set; } = string.Empty;

        /// <summary>
        /// 工单编号
        /// </summary>
        public string WorkOrderCode { get; set; } = string.Empty;

        /// <summary>
        /// 唯一工单编号
        /// </summary>
        public string WorkOrderNo { get; set; } = string.Empty;

        /// <summary>
        /// 工序名称
        /// </summary>
        public string ProcessName { get; set; } = string.Empty;

        /// <summary>
        /// 工序编码
        /// </summary>
        public string ProcessCode { get; set; } = string.Empty;

        /// <summary>
        /// 流程标题
        /// </summary>
        public string Title { get; set; } = string.Empty;

        /// <summary>
        /// 申请人
        /// </summary>
        public string ApplicantUserName { get; set; } = string.Empty;

        /// <summary>
        /// 当前审批步骤
        /// </summary>
        public string? StepName { get; set; }

        /// <summary>
        /// 审批人
        /// </summary>
        public string? AuditUserName { get; set; }

        /// <summary>
        /// 流程状态
        /// </summary>
        public string Status { get; set; } = string.Empty;

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 完成时间
        /// </summary>
        public DateTime? CompletedTime { get; set; }

        /// <summary>
        /// 表单数据（JSON格式）
        /// </summary>
        public string? FormData { get; set; }
    }
} 